home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
earkit
/
news
/
thor
/
rexx
/
bbsread
/
addaminetfilelist.br
next >
Wrap
Text File
|
1998-05-24
|
5KB
|
196 lines
/*
* $VER: AddAmiNetFileList.br 3.4 (16.5.97)
*
* Arexx script to add a AmiNet RECENT/INDEX list to the database.
*
* Based on AddAmiNetFileList.br v3.1 provided by the THOR team.
*
* Modified by Henrik Dissing to handle dates and file sizes correctly.
*
* V3.4 changes done by Eirik Synnes
*
*
* V3.3: Now also strips '*' from date field to prevent "Aritmethic
* conversion error" when loading INDEX files from sites
* not holdning the full database.
* Now, hopefully, detects lists in "illegal" formats
*
* V3.4: The ouput has been made simpler in order to increase overall speed
* Added QUIET switch for no output (about 10% faster)
* Made some of the error messages a bit more verbose
*
*/
options results
/* trace results */
parse arg argument
template = 'BBSNAME/A,FILENAME/A,QUIET/S'
if argument = '' | argument = '?' then
do
say '$VER: AddAminetFileList.br' || subword(sourceline(2), 4)
say 'Template: 'template
say 'Example: AddAminetFileList.br "Internet" "Work:Files/INDEX" QUIET'
exit
end
if ~show('p', 'BBSREAD') then do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
address BBSREAD
READARGS template ARGS CMDLINE argument
if rc ~= 0 then
do
say BBSREAD.LASTERROR
say 'Template: 'template
say 'Example: AddAminetFileList.br "Internet" "Work:Files/INDEX" QUIET'
exit
end
if ~open(fh,ARGS.FILENAME,'Read') then
do
say 'Unable to open file: ' || args.FILENAME
exit
end
if ~(args.QUIET) then indexlength = seek(fh, 0, 'E'); call seek(fh, 0, 'B')
rc = 0
signal on ERROR
signal on BREAK_C
signal on HALT
'BUFMODE COPYBACK' /* Enable copyback buffer mode */
aline = readln(fh)
ltype = word(aline, 2)
ldate = word(aline, words(aline))
parse var ldate day '-' month '-' year
day = right(day, 2, '0')
select
when month == 'Jan' then month = '01'
when month == 'Feb' then month = '02'
when month == 'Mar' then month = '03'
when month == 'Apr' then month = '04'
when month == 'May' then month = '05'
when month == 'Jun' then month = '06'
when month == 'Jul' then month = '07'
when month == 'Aug' then month = '08'
when month == 'Sep' then month = '09'
when month == 'Oct' then month = '10'
when month == 'Nov' then month = '11'
when month == 'Dec' then month = '12'
otherwise
say "Unexpected month identifier in header:" month
call HALT
end
year = right(year, 2, '0')
if year < 95 then
year = '20'year
else
year = '19'year
ldate = date('i', year || month || day, 's') * 86400
do until eof(fh)
aline = readln(fh)
do while left(aline, 1) == '|'
aline = readln(fh)
if left(aline, 5) == '|File' then
do
legalhead = '|File Dir Size Age Description'
if left(aline, length(legalhead)) ~== legalhead then
do
say "Unexpected list format in " || ARGS.FILENAME
say "List header must look exactly like this:"
say legalhead
call HALT
end
end
end
if aline == "" then iterate
if ltype == "Complete" then
do
parse var aline 1 fname 20 farea 31 fsize 36 fage 40 fdesc
fname = strip(fname)
farea = strip(farea)
fsize = strip(fsize)
fdate = ldate - (strip(fage, 'B', ' +*') * 7 * 86400)
fdesc = strip(fdesc)
end
else if ltype == "Recent" then
do
parse var aline 1 fname 20 farea 31 fsize 36 fdesc
fname = strip(fname)
farea = strip(farea)
fsize = strip(fsize, 'B', ' +')
fdate = ldate
fdesc = strip(fdesc)
end
else
do
say "Unexpected format of first line in" ARGS.FILENAME
call HALT
end
if right(fsize, 1) == 'M' then mega = 1
else mega = 0
fsize = compress(fsize, 'KM')
if ~datatype(fsize,'N') then fsize = 0
if mega == 1 then
fsize = trunc(fsize * 1024.0)
fsize = fsize * 1024
'CONFIGFAREA "' || ARGS.BBSNAME || '"' farea
if fdesc ~= '' then
do
drop BRFILE.
BRFILE.NAME = fname
BRFILE.SIZE = fsize
BRFILE.DATE = fdate
BRFILE.DESCRIPTION.COUNT = 1
BRFILE.DESCRIPTION.1 = fdesc
'WRITEBRFILE "' || ARGS.BBSNAME || '"' farea stem BRFILE
if ~(args.QUIET) then do
curperc = (seek(fh, 0) / indexlength) * 100
if curperc ~= 100 then curperc = left(curperc, index(curperc, '.') - 1)
if (curperc ~= lastperc) | (farea ~= lastarea) then do
say '1B'x'[1A' || '1B'x'[K' || '(' || curperc || '% done) Adding files from: 'farea
lastperc = curperc; lastarea = farea
end
end
end
end
ERROR:
HALT:
BREAK_C:
if(rc ~= 0) then
do
say 'Error' rc 'in line' SIGL ':' BBSREAD.LASTERROR
end
'BUFMODE ENDCOPYBACK' /* Disable copyback buffer mode */
exit